﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ActivateYourGlutes.Infrastructure;
using ActivateYourGlutes.Infrastructure.MembershipServices;

namespace ActivateYourGlutes.Model.Providers
{
    public class MembershipProviderBase : ProviderBase
    {
        protected IMembershipService MembershipService { get; private set; }

        protected MembershipProviderBase(IEntityModelFactory factory, IMembershipService service)
            : base(factory)
        {
            MembershipService = service;
        }

        protected void AuthorizeAccountAsAdministrator(Contracts.Account accessingAccount)
        {
            if (!MembershipService.IsAdministrator(accessingAccount.Username))
                throw new AuthorizationException("You do not have rights to perform this function");
        }
    }
}
